package com.prs.crm.service.hr.impl;

import java.io.File;

import com.prs.crm.context.Attach;
import com.prs.crm.context.Constrains;
import com.prs.crm.context.FileUtil;
import com.prs.crm.dao.hr.RedeployDao;
import com.prs.crm.domain.hr.Person;
import com.prs.crm.domain.hr.Redeploy;
import com.prs.crm.service.hr.PersonService;
import com.prs.crm.service.hr.RedeployService;
import com.prs.crm.service.impl.BaseServiceImpl;

public class RedeployServiceImpl extends BaseServiceImpl<Redeploy,RedeployDao> implements RedeployService{
	private PersonService personService;

	@Override
	public void saveRedeploy(Redeploy redeploy, Person person, File file,
			String fileName) {
		// TODO Auto-generated method stub
		Attach attach = FileUtil.getInstance().saveFile(file, fileName, "", Constrains.UPLOAD_DIC_REDEPLOY);
		if(attach.getSrc() != null) {
			redeploy.setAttach(attach.getSrc());
		}
		person.setDept(redeploy.getDept());
		person.setRole(redeploy.getRole());
		person.setSalary(redeploy.getSalary());
		
		this.getPersonService().save(person);
		redeploy.setPerson(person);
		this.getDao().save(redeploy);
	}

	public void setPersonService(PersonService personService) {
		this.personService = personService;
	}

	public PersonService getPersonService() {
		return personService;
	}

}
